<!DOCTYPE
  html PUBLIC "-//W3C//DTD XHTML 1.0//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<!-- Progeny Proprietary Information
     Copyright 2000-2005 Progeny Systems Corporation. All Rights Reserved.
-->

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:xf="http://www.w3.org/2002/xforms" xml:lang="en">
  <head>
    <title>Repeats/Calculations</title>
    
    <link rel="stylesheet" type="text/css" href="xforms.css" />
    
    <script type="text/javascript" src="../../formfaces.js"></script>
    
    <xf:model>
      <xf:instance>
        <customers xmlns="">
          <customer>
            <first>John</first>
            <last>Kugelman</last>
          
            <books>
              <book name="The Gunslinger">
                <price>16.50</price>
                
                <author>
                  <first>Stephen</first>
                  <last>King</last>
                </author>
              </book>
              
              <book name="The Drawing of the Three">
                <price>24.50</price>
                
                <author>
                  <first>Stephen</first>
                  <last>King</last>
                </author>
              </book>
              
              <book name="The Waste Lands">
                <price>23.10</price>
                
                <author>
                  <first>Stephen</first>
                  <last>King</last>
                </author>
              </book>
              
              <book name="The Sandman: Endless Nights">
                <price>16.47</price>
                
                <author>
                  <first>Neil</first>
                  <last>Gaiman</last>
                </author>
              </book>
            </books>
          </customer>
          
          <customer>
            <first>Susan</first>
            <last>Borgrink</last>
          
            <books>
              <book name="The Unbearable Lightness of Being">
                <price>13.95</price>
                
                <author>
                  <first>Milan</first>
                  <last>Kundera</last>
                </author>
              </book>
              
              <book name="One Hundred Years of Solitude">
                <price>14.00</price>
                
                <author>
                  <first>Gabriel</first>
                  <last>Garc&#237;a M&#225;rquez</last>
                </author>
              </book>
            </books>
          </customer>
        </customers>
      </xf:instance>
    </xf:model>
  </head>
  
  <body>
    <p>This page demonstrates nested repeats. You should see two customers and the
       list of books they've bought. The prices of the books are editable. If you
       change a price the total will automatically update.</p>
  
    <h1>Customer Database</h1>
  
    <xf:repeat nodeset="customer"><div>
      <h2><xf:output value="position()"/>. <xf:output ref="first"/> <xf:output ref="last"/></h2>
      
      <table border="1">
        <thead>
          <tr>
            <td>&nbsp;</td>
            <th>Price</th>
            <th>Book</th>
            <th>Author</th>
          </tr>
        </thead>
        
        <tbody xf:repeat-nodeset="books/book">
          <tr>
            <td><xf:output value="position()"/>.</td>
          
            <td><xf:input  ref="price"><xf:label/></xf:input></td>
            <td><xf:output ref="@name"/></td>
            
            <td>
              <xf:group ref="author">
                <xf:output ref="first"/>
                <xf:output ref="last"/>
              </xf:group>
            </td>
          </tr>
        </tbody>
      </table>
      
      <p>Total: $<xf:output value="sum(books/book/price)"/></p>
    </div></xf:repeat>
    
    <p id="status"></p>
  </body>
</html>